package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "quotation_", schema = "crm")
public class Quotation {
    private int quotationId;
    private String quotationTheme;
    private String quotationNo;
    private Integer quotationStatus;
    private Integer quotationClassify;
    private Date quotationDate;
    private BigDecimal quotationPrice;
    private String quotationDelivery;
    private String quotationPayment;
    private String quotationPackage;
    private String quotationRemarks;
    private String quotationContactName;
    private Integer quotationAppStatus;
    private List<Approval> approvalsByQuotationId;
    private List<ApprovalRecord> approvalRecordsByQuotationId;
    private List<ProductDetail> productDetailsByQuotationId;
    private Opportunity opportunityByOppId;
    private Customer customerByCustomerId;
    private Employee employeeByEmpId;
    private Employee employeeByAppEmpId;// 审批人

    @Id
    @Column(name = "quotation_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getQuotationId() {
        return quotationId;
    }

    public void setQuotationId(int quotationId) {
        this.quotationId = quotationId;
    }

    @Basic
    @Column(name = "quotation_theme", nullable = true, length = 255)
    public String getQuotationTheme() {
        return quotationTheme;
    }

    public void setQuotationTheme(String quotationTheme) {
        this.quotationTheme = quotationTheme;
    }

    @Basic
    @Column(name = "quotation_no", nullable = true, length = 255)
    public String getQuotationNo() {
        return quotationNo;
    }

    public void setQuotationNo(String quotationNo) {
        this.quotationNo = quotationNo;
    }

    @Basic
    @Column(name = "quotation_status", nullable = true)
    public Integer getQuotationStatus() {
        return quotationStatus;
    }

    public void setQuotationStatus(Integer quotationStatus) {
        this.quotationStatus = quotationStatus;
    }

    @Basic
    @Column(name = "quotation_classify", nullable = true)
    public Integer getQuotationClassify() {
        return quotationClassify;
    }

    public void setQuotationClassify(Integer quotationClassify) {
        this.quotationClassify = quotationClassify;
    }


    @Basic
    @Column(name = "quotation_date", nullable = true)
    public Date getQuotationDate() {
        return quotationDate;
    }

    public void setQuotationDate(Date quotationDate) {
        this.quotationDate = quotationDate;
    }

    @Basic
    @Column(name = "quotation_price", nullable = true, precision = 2)
    public BigDecimal getQuotationPrice() {
        return quotationPrice;
    }

    public void setQuotationPrice(BigDecimal quotationPrice) {
        this.quotationPrice = quotationPrice;
    }

    @Basic
    @Column(name = "quotation_delivery", nullable = true, length = 255)
    public String getQuotationDelivery() {
        return quotationDelivery;
    }

    public void setQuotationDelivery(String quotationDelivery) {
        this.quotationDelivery = quotationDelivery;
    }

    @Basic
    @Column(name = "quotation_payment", nullable = true, length = 255)
    public String getQuotationPayment() {
        return quotationPayment;
    }

    public void setQuotationPayment(String quotationPayment) {
        this.quotationPayment = quotationPayment;
    }

    @Basic
    @Column(name = "quotation_package", nullable = true, length = 255)
    public String getQuotationPackage() {
        return quotationPackage;
    }

    public void setQuotationPackage(String quotationPackage) {
        this.quotationPackage = quotationPackage;
    }

    @Basic
    @Column(name = "quotation_remarks", nullable = true, length = 255)
    public String getQuotationRemarks() {
        return quotationRemarks;
    }

    public void setQuotationRemarks(String quotationRemarks) {
        this.quotationRemarks = quotationRemarks;
    }


    @Basic
    @Column(name = "quotation_contact_name", nullable = true, length = 255)
    public String getQuotationContactName() {
        return quotationContactName;
    }

    public void setQuotationContactName(String quotationContactName) {
        this.quotationContactName = quotationContactName;
    }

    @Basic
    @Column(name = "quotation_app_status", nullable = true, length = 255)
    public Integer getQuotationAppStatus() {
        return quotationAppStatus;
    }

    public void setQuotationAppStatus(Integer quotationAppStatus) {
        this.quotationAppStatus = quotationAppStatus;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Quotation quotation = (Quotation) o;
        return quotationId == quotation.quotationId &&
                Objects.equals(quotationTheme, quotation.quotationTheme) &&
                Objects.equals(quotationNo, quotation.quotationNo) &&
                Objects.equals(quotationStatus, quotation.quotationStatus) &&
                Objects.equals(quotationClassify, quotation.quotationClassify) &&
                Objects.equals(quotationDate, quotation.quotationDate) &&
                Objects.equals(quotationPrice, quotation.quotationPrice) &&
                Objects.equals(quotationDelivery, quotation.quotationDelivery) &&
                Objects.equals(quotationPayment, quotation.quotationPayment) &&
                Objects.equals(quotationPackage, quotation.quotationPackage) &&
                Objects.equals(quotationRemarks, quotation.quotationRemarks) &&
                Objects.equals(quotationContactName, quotation.quotationContactName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(quotationId, quotationTheme, quotationNo, quotationStatus,quotationClassify ,quotationDate, quotationPrice, quotationDelivery, quotationPayment, quotationPackage, quotationRemarks, quotationContactName);
    }

    @OneToMany(mappedBy = "quotationByQuotationId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Approval> getApprovalsByQuotationId() {
        return approvalsByQuotationId;
    }

    public void setApprovalsByQuotationId(List<Approval> approvalsByQuotationId) {
        this.approvalsByQuotationId = approvalsByQuotationId;
    }

    @OneToMany(mappedBy = "quotationByQuotationId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<ApprovalRecord> getApprovalRecordsByQuotationId() {
        return approvalRecordsByQuotationId;
    }

    public void setApprovalRecordsByQuotationId(List<ApprovalRecord> approvalRecordsByQuotationId) {
        this.approvalRecordsByQuotationId = approvalRecordsByQuotationId;
    }

    @OneToMany(mappedBy = "quotationByQuotationId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<ProductDetail> getProductDetailsByQuotationId() {
        return productDetailsByQuotationId;
    }

    public void setProductDetailsByQuotationId(List<ProductDetail> productDetailsByQuotationId) {
        this.productDetailsByQuotationId = productDetailsByQuotationId;
    }

    @ManyToOne
    @JoinColumn(name = "opp_id", referencedColumnName = "opp_id")
    public Opportunity getOpportunityByOppId() {
        return opportunityByOppId;
    }

    public void setOpportunityByOppId(Opportunity opportunityByOppId) {
        this.opportunityByOppId = opportunityByOppId;
    }


    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }

    @ManyToOne
    @JoinColumn(name = "emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByEmpId() {
        return employeeByEmpId;
    }

    public void setEmployeeByEmpId(Employee employeeByEmpId) {
        this.employeeByEmpId = employeeByEmpId;
    }

    @ManyToOne
    @JoinColumn(name = "app_emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByAppEmpId() {
        return employeeByAppEmpId;
    }

    public void setEmployeeByAppEmpId(Employee employeeByAppEmpId) {
        this.employeeByAppEmpId = employeeByAppEmpId;
    }

}

